package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.business.WorkReportTypeEnum;
import lombok.Getter;

/**
 * @description: 工作报告截止提交日期枚举
 * @Author: hongxiao
 * @date: 2019-03-13 14:54
 * @since v1.0
 */
@Getter
public enum WorkReportDeadDayTypeEnum {
    /**
     * 截止日期类型
     */
    TODAY(1, "enum.workReportDeadDayType.name.today", WorkReportTypeEnum.DAILY.getType()),
    TOMORROW(2, "enum.workReportDeadDayType.name.tomorrow", WorkReportTypeEnum.DAILY.getType()),
    FRIDAY(1, "enum.workReportDeadDayType.name.friday", WorkReportTypeEnum.WEEKLY.getType()),
    SATURDAY(2, "enum.workReportDeadDayType.name.saturday", WorkReportTypeEnum.WEEKLY.getType()),
    SUNDAY(3, "enum.workReportDeadDayType.name.sunday", WorkReportTypeEnum.WEEKLY.getType()),
    MONDAY(4, "enum.workReportDeadDayType.name.monday", WorkReportTypeEnum.WEEKLY.getType()),
    FIRST_DAY_OF_NEXT_MONTH(1, "enum.workReportDeadDayType.name.first_day_of_next_month", WorkReportTypeEnum.MONTHLY.getType()),
    LAST_DAY_OF_MONTH(2, "enum.workReportDeadDayType.name.last_day_of_month", WorkReportTypeEnum.MONTHLY.getType()),
    ;

    /**
     * 筛选值
     */
    private int code;
    /**
     * 名称
     */
    private String name;
    /**
     * 工作报告类型
     */
    private int type;

    WorkReportDeadDayTypeEnum(int code, String name, int type) {
        this.code = code;
        this.name = name;
        this.type = type;
    }

    /**
     * 根据值和类型获取实体
     * @param code 值
     * @param type 工作报告类型
     * @return
     * @throws
     *
     * @author hongxiao
     * @date: 2019-03-13 16:12
     * @since v1.0
     * @version v1.0
     */
    public static WorkReportDeadDayTypeEnum getByCodeType(Integer code, Integer type) {
        if (code == null || type == null) {
            return null;
        }
        for (WorkReportDeadDayTypeEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode()) && type.equals(cacheCode.getType())) {
                return cacheCode;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
